package Controller.Eboard;

	import javax.servlet.http.HttpServletRequest;
	import javax.servlet.http.HttpServletResponse;

	import org.springframework.validation.BindException;
	import org.springframework.web.servlet.ModelAndView;
	import org.springframework.web.servlet.mvc.AbstractCommandController;

	import Bean.eboardBean;
	import Dao.eboardDao;

	public class EboardinsertContoller extends AbstractCommandController{
		private eboardDao dao;

		public void setDao(eboardDao dao) {
			this.dao = dao;
		}
		@Override
		protected ModelAndView handle(HttpServletRequest req,
				HttpServletResponse res, Object obj, BindException arg3)
				throws Exception {
			req.setCharacterEncoding("UTF-8");
			
			String contents = req.getParameter("eb_context");
			contents = contents.replace("\r\n", "<br>");
			System.out.println(req.getParameter("eb_context"));
			System.out.println(req.getParameter("eb_title"));
			eboardBean bean = (eboardBean)obj;
			
			bean.setEb_context(contents);
			
			System.out.println(bean.getEb_context());
			System.out.println(bean.getEb_title());
			
			ModelAndView mav = new ModelAndView();
			
			dao.ebinsert(bean);
			mav.setViewName("redirect:/eboardmain.eboard");
			return mav;
		}
	}
